package com.wn.user.util;

import com.wn.common.pojo.User;

/**
 * @BelongsProject: shared_parking
 * @BelongsPackage: com.wn.common.util
 * @Author: 廖刚
 * @CreateTime: 2020-06-19 10:44
 * @Description: 向管理员申请成为啥角色
 */
public class Apply2AdminUtil {


    /**
     * 告诉管理员需要某个用户的申请
     * @param user
     * @return
     */
    public static boolean  sendEmail(User user){
        if(user == null || user.getRoleId() == null || user.getUsername() == null){
            return false;
        }
        String content = null;
        if( user.getRoleId() == 3){
            //申请成为抢租客
            content = user.getUsername() + "申请成为抢租客";
        }else if(user.getRoleId() == 2){
            //申请成为出租客
            content = user.getUsername() + "申请成为出租客";
        }else if (user.getRoleId() == 1){
            //申请成为物业方
            content = user.getUsername() + "申请成为物业方";
        }
        //System.out.println("测试"+content);
        try {

            //EmailUtil.sendMail("964764278@qq.com", "oitduadeuuifbfjd", "smtp.qq.com", "964764278@qq.com", "liaog1234@163.com", "共享汽车审核", "xxx");
             EmailUtil.sendMail("964764278@qq.com", "oitduadeuuifbfjd", "smtp.qq.com", "964764278@qq.com", "liaog1234@163.com", "共享车位审核", content);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return true;
    }


    /**
     * 告诉用户申请通过
     */
    public static void  applySuccess(User user){
        String content = null;
        if( user.getRoleId() == 3){
            //申请成为抢租客
            content = "恭喜您，"+user.getUsername() + "，成功成为抢租客";
        }else if(user.getRoleId() == 2){
            //申请成为出租客
            content = "恭喜您，"+user.getUsername() + "，成功成为出租客";
        }else if (user.getRoleId() == 1){
            //申请成为物业方
            content = "恭喜您，"+user.getUsername() + "，成功成为物业方";
        }

        try {
            System.out.println(user);
            EmailUtil.sendMail("964764278@qq.com", "oitduadeuuifbfjd", "smtp.qq.com", "964764278@qq.com", user.getEmail(), "共享车位审核", content);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
